﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace VoicePhone.Common
{
    public class DateTimeHelper
    {
        public static string GetStrTime(int seconds, bool defaultEmpty = false)
        {
            if (defaultEmpty && seconds == 0) return "";
            string hour = (seconds / 3600).ToString().PadLeft(2, '0');
            string minute = (seconds % 3600 / 60).ToString().PadLeft(2, '0');
            string second = (seconds % 3600 % 60).ToString().PadLeft(2, '0');
            return $"{hour}:{minute}:{second}";
        }

        public static string LongToDateTimeString(string strResource)
        {
            if (strResource.Length == 8 || strResource.Length == 14 || strResource.Length == 17)
            {
                if (strResource.Length == 17)
                    strResource = strResource.Insert(14, ".");
                if (strResource.Length != 8)
                {
                    strResource = strResource.Insert(12, ":");
                    strResource = strResource.Insert(10, ":");
                    strResource = strResource.Insert(8, " ");
                }
                strResource = strResource.Insert(6, "-");
                strResource = strResource.Insert(4, "-");
            }
            return strResource;
        }
    }
}
